----------------------------
-- Simplistic Street
-- by Arran
--
-- Project Started - October 20, 2009
-- Completion -None
----------------------------

local draw = draw
local surface = surface
local HUDToHide = {"CHudHealth", "CHudBattery", "CHudAmmo", "CHudSecondaryAmmo"}

surface.CreateFont("HudHintTextLarge", 20, 1000, true, false, "Text_HUD")

-- Textures
local HeartTexture = surface.GetTextureID( "gui/silkicons/heart" )
local MoneyTexture = surface.GetTextureID( "gui/silkicons/money" )
local ManTexture = surface.GetTextureID( "gui/silkicons/man" )
local ArmorTexture = surface.GetTextureID( "gui/silkicons/shield" )
local BulletTexture = surface.GetTextureID( "gui/silkicons/bullet" )
local GuiltTexture = surface.GetTextureID( "gui/silkicons/exclamation" )

-- Border and Background
local BorderColor = Color( 0, 0, 0, 255 )
local BackgroundColor = Color( 255, 255, 255, 200 )

-- Health
local HealthMainColor = Color( 255, 75, 75, 255 )
local HealthFill = Color( 255, 0, 0, 255 )

-- Stamina
local StaminaWidth = GetStamina() * 1.73
local StaminaMainColor = Color( 0, 65, 255, 255 )
local StaminaFill = Color( 0, 25, 255, 255 )

-- Guilt
local GuiltMainColor = Color( 255, 170, 120, 255 )
local GuiltFill = Color( 255, 170, 0, 255 )

-- Armor
local ArmorMainColor = Color( 110, 110, 110, 255 )
local ArmorFill = Color( 100, 100, 100, 255 )


local function HUDPaint()
	if !LocalPlayer():Alive() then return end
	if  LocalPlayer():GetActiveWeapon() == NULL then return end

	surface.SetDrawColor( BorderColor )
	surface.DrawOutlinedRect( 24, 11, 175, 20 )

	surface.SetDrawColor( BackgroundColor )
	surface.DrawRect( 25, 12, 173, 18 )

	surface.SetDrawColor( HealthFill )
	surface.DrawRect( 25, 18, LocalPlayer():Health() * 1.73, 12 )

	surface.SetDrawColor ( HealthMainColor )
	surface.DrawRect( 25, 12, LocalPlayer():Health() * 1.73, 6 )

	surface.SetTexture( HeartTexture )
	surface.SetDrawColor( 255, 255, 255, 255 )
	surface.DrawTexturedRect( 4, 12, 16, 16 )

	surface.SetDrawColor( BorderColor )
	surface.DrawOutlinedRect( 24, 34, 175, 20 )

	surface.SetDrawColor( BackgroundColor )
	surface.DrawRect( 25, 35, 173, 18 )

	surface.SetDrawColor( StaminaFill )
	surface.DrawRect( 25, 41, StaminaWidth, 12 )

	surface.SetDrawColor ( StaminaMainColor )
	surface.DrawRect( 25, 35, StaminaWidth, 6 )

	surface.SetTexture( ManTexture )
	surface.SetDrawColor( 255, 255, 255, 255 )
	surface.DrawTexturedRect( 4, 35, 16, 16 )


	if LocalPlayer().GuiltNumber then
		surface.SetDrawColor( BorderColor )
		surface.DrawOutlinedRect( 24, 57, 175, 20 )

		surface.SetDrawColor( BackgroundColor )
		surface.DrawRect( 25, 58, 173, 18 )

		surface.SetDrawColor( GuiltFill )
		surface.DrawRect( 25, 64, LocalPlayer().GuiltNumber * 1.73, 12 )

		surface.SetDrawColor ( GuiltMainColor )
		surface.DrawRect( 25, 58, LocalPlayer().GuiltNumber * 1.73, 6 )

		surface.SetTexture( GuiltTexture )
		surface.SetDrawColor( 255, 255, 255, 255 )
		surface.DrawTexturedRect( 4, 58, 16, 16 )
	end

	if 	LocalPlayer():Armor() > 0 and LocalPlayer():Alive() then
		surface.SetDrawColor( BorderColor )
		surface.DrawOutlinedRect( 24, 80, 175, 20 )

		surface.SetDrawColor( BackgroundColor )
		surface.DrawRect( 25, 81, 173, 18 )

		surface.SetDrawColor( ArmorFill )
		surface.DrawRect( 25, 87, LocalPlayer():Armor() * 1.73, 12 )

		surface.SetDrawColor ( ArmorMainColor )
		surface.DrawRect( 25, 81, LocalPlayer():Armor() * 1.73, 6 )

		surface.SetTexture( ArmorTexture )
		surface.SetDrawColor( 255, 255, 255, 255 )
		surface.DrawTexturedRect( 4, 81, 16, 16 )

		draw.SimpleTextOutlined("Money: $" .. LocalPlayer():GetNWInt("Money"), "Text_HUD", 27, 100, Color(255, 255, 255, 255), TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT, 1, Color(0, 0, 0, 200))
		surface.SetTexture( MoneyTexture )
		surface.SetDrawColor( 255, 255, 255, 255 )
		surface.DrawTexturedRect( 4, 103, 16, 16 )
	else
		draw.SimpleTextOutlined("Money: $" .. LocalPlayer():GetNWInt("Money"), "Text_HUD", 27, 77, Color(255, 255, 255, 255), TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT, 1, Color(0, 0, 0, 200))
		surface.SetTexture( MoneyTexture )
		surface.SetDrawColor( 255, 255, 255, 255 )
		surface.DrawTexturedRect( 4, 81, 16, 16 )
	end

	local Ammunition = LocalPlayer():GetActiveWeapon():Clip1()
		for i = 1, Ammunition do 
			surface.SetTexture( BulletTexture )
			surface.SetDrawColor( 255, 255, 255, 255 )
			surface.DrawTexturedRect( ScrW() - 90-i*8, ScrH() - 40, 32, 32 )

			draw.SimpleTextOutlined( LocalPlayer():GetActiveWeapon():Clip1().."/".. LocalPlayer():GetAmmoCount(LocalPlayer():GetActiveWeapon():GetPrimaryAmmoType()), "Text_HUD", ScrW() - 70, ScrH() - 30, Color(255, 255, 255, 255), TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT, 1, Color(0, 0, 0, 200))
		end
	end
hook.Add( "HUDPaint", "PaintOurHud", HUDPaint )
hook.Add("HUDShouldDraw", "HideHUD", function(Hud) return !table.HasValue(HUDToHide, Hud) end )